package xin.marcher.module.inventory.mq.producer;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import xin.marcher.module.common.constants.RocketMqConstant;
import xin.marcher.module.inventory.domain.response.WarningInventoryDTO;

/**
 * 库存预警的生产队列
 *
 * 
 */
@Slf4j
@Component
public class WarningInventoryProducer {
    @Autowired
    private DefaultProducer defaultProducer;

    /**
     * 库存预警的消息 MQ生产
     *
     * @param warningInventoryDTO
     */
    public void sendWarningInventory(WarningInventoryDTO warningInventoryDTO) {
        //发送分库存预警消息
        defaultProducer.sendMessage(RocketMqConstant.WARNING_INVENTORY_TOPIC,
                JSONObject.toJSONString(warningInventoryDTO), "库存预警");
    }
}
